<template>
	<view class="page all">
		<form @submit="update">
			<picker mode="date" @change="change" class="piker">
				<view>{{birthday || "请选择"}}</view>
			</picker>
			<button type="primary" class="btn" form-type="submit">提交</button>
		</form>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				birthday:""
			}
		},
		methods: {
			change(e){
				console.log(e)
				this.birthday=e.detail.value
			},
			update(){
				uni.showLoading({
						title:"上传中，请稍后"
				})
				let me=this
				let userInfo=uni.getStorageSync("user")[0]
				let token=userInfo.token
				uni.request({
					url:me.root+'/api/updateBirthday?birthday='+me.birthday,
					header:{
						"token":token
					},
					success(res) {
						console.log(res)
						if(res.data.err==0){
							uni.setStorageSync("user",res.data.data)
							uni.navigateTo({
								url:"../meInfo/meInfo"
							})
						}else{
							uni.showToast({
								title:res.data.msg
							})
						}
					},
					complete() {
						uni.hideLoading()
					}
				})
			}
		},
		onLoad(params) {
			this.birthday=params.birthday
		}
	}
</script>

<style scoped>
.piker{
		background-color: red;
		padding: 30upx;
		margin-bottom: 40upx;
		margin-top: 20upx;
		background-color: #FFF;
	}
	.btn{
		width: 700upx;
	}
</style>
